import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import path from 'path';

export default defineConfig({
    plugins: [vue()],
    build: {
        lib: {
            entry: path.resolve(__dirname, 'index.js'), // 你的入口（已经 export design, preview）
            fileName: (format) => `survey.${format}.js`, // 生成 survey.es.js survey.cjs.js
            formats: ['es', 'cjs']
        },
        // Ensure Rollup options are passed to the library build
        rollupOptions: {
            // 不将 Vue 打包进库，作为外部依赖
            external: ['vue'],
            output: {
                globals: {
                    vue: 'Vue'
                }
            }
        },
        outDir: 'dist',
        emptyOutDir: true
    }
});